package com.ewili.x.special.dao.inter;

import com.ewili.x.special.entity.Stock;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

public interface StockDao extends JpaRepository<Stock, Long> {

    Stock findByCode(String code);

    @Override
    List<Stock> findAll();

    @Transactional
    @Modifying
    @Query(value = "UPDATE Stock s SET s.lastHisRecordDate = ?2 WHERE s.code = ?1")
    void updateLastRecordDate(String stockCode, Date date);

    @Transactional
    @Modifying
    @Query(value = "UPDATE Stock s SET s.lastFinanceReportDate = ?2 WHERE s.code = ?1")
    void updatelastFinanceReportDate(String stockCode, Date date);

}
